using com.youzu.warh.protocol;
using CustomDataStruct;
using ProtoBuf.Serializers;

namespace battle
{
    public class CoordinateDecorator: ICustomProtoSerializer
    {
        public void SetValue(object target, object value, int fieldNumber)
        {
            Coordinate data = target as Coordinate;
            if (data == null)
            {
                return;
            }
            switch (fieldNumber)
            {
                case 1:
                    data.xAxis = ValueObject.Value<float>(value);
                    break;
                case 3:
                    data.zAxis = ValueObject.Value<float>(value);
                    break;
            }
        }

        public object GetValue(object target, int fieldNumber)
        {
            Coordinate data = target as Coordinate;
            if (data == null)
            {
                return null;
            }
            switch (fieldNumber)
            {
                case 1:
                    return ValueObject.Get(data.xAxis);
                case 3:
                    return ValueObject.Get(data.zAxis);
            }
            return null;
        }
    }
}